package com.mk.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mk.web.model.Bottle;
import com.mk.web.service.BottleService;
import com.mk.web.service.impl.BottleServiceImpl;

/**
 * Created by WangChen on 2018/11/27 17:06.
 */
@WebServlet("/saveBottle")
public class BottleSaveServlet extends HttpServlet {

    private BottleService bottleService = new BottleServiceImpl();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("name");
        double size = Double.parseDouble(req.getParameter("size"));

        Bottle bottle = new Bottle();
        bottle.setSize(size);
        bottle.setName(name);
        bottleService.save(bottle);
    }
}
